package p270jp.pxv.android.view;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.databinding.DataBindingUtil;
import java.util.Objects;
import p045be.C1060c;
import p062c4.ViewBindings;
import p090d0.C2518n;
import p270jp.pxv.android.R;
import p274k2.ContextCompat;
import p314lg.SpinnerDropdownItemNovelBackgroundBinding;
import p314lg.SpinnerDropdownItemNovelFontBinding;
import p314lg.SpinnerItemNovelBackgroundBinding;
import p314lg.SpinnerItemNovelFontBinding;
import p314lg.ViewNovelSettingBinding;
import p347mm.NovelTypeface;

/* renamed from: jp.pxv.android.view.NovelSettingView */
/* loaded from: classes2.dex */
public class NovelSettingView extends LinearLayout {

    /* renamed from: h */
    public static final float[] f19602h = {12.0f, 14.0f, 16.0f, 18.0f, 20.0f};

    /* renamed from: i */
    public static final float[] f19603i = {1.25f, 1.5f, 1.75f, 2.0f, 2.25f};

    /* renamed from: a */
    public ViewNovelSettingBinding f19604a = (ViewNovelSettingBinding) DataBindingUtil.m11370c(LayoutInflater.from(getContext()), R.layout.view_novel_setting, this, true);

    /* renamed from: b */
    public C4387f f19605b;

    /* renamed from: c */
    public C4386e f19606c;

    /* renamed from: d */
    public OnFontSizeChangedListener f19607d;

    /* renamed from: e */
    public OnLineSpaceChangedListener f19608e;

    /* renamed from: f */
    public OnFontChangedListener f19609f;

    /* renamed from: g */
    public OnColorChangedListener f19610g;

    /* renamed from: jp.pxv.android.view.NovelSettingView$OnColorChangedListener */
    /* loaded from: classes2.dex */
    public interface OnColorChangedListener {
        void onColorChanged(int i, int i2, int i3, String str);
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$OnFontChangedListener */
    /* loaded from: classes2.dex */
    public interface OnFontChangedListener {
        void onFontChanged(Typeface typeface, String str);
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$OnFontSizeChangedListener */
    /* loaded from: classes2.dex */
    public interface OnFontSizeChangedListener {
        void onFontSizeChanged(float f);
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$OnLineSpaceChangedListener */
    /* loaded from: classes2.dex */
    public interface OnLineSpaceChangedListener {
        void onLineSpaceChanged(float f);
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$a */
    /* loaded from: classes2.dex */
    public class C4382a implements SeekBar.OnSeekBarChangeListener {
        public C4382a() {
            NovelSettingView.this = r1;
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onStopTrackingTouch(SeekBar seekBar) {
            if (NovelSettingView.this.f19607d != null) {
                float[] fArr = NovelSettingView.f19602h;
                NovelSettingView.this.f19607d.onFontSizeChanged(NovelSettingView.f19602h[seekBar.getProgress()]);
            }
        }
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$b */
    /* loaded from: classes2.dex */
    public class C4383b implements SeekBar.OnSeekBarChangeListener {
        public C4383b() {
            NovelSettingView.this = r1;
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override // android.widget.SeekBar.OnSeekBarChangeListener
        public void onStopTrackingTouch(SeekBar seekBar) {
            if (NovelSettingView.this.f19608e != null) {
                float[] fArr = NovelSettingView.f19602h;
                NovelSettingView.this.f19608e.onLineSpaceChanged(NovelSettingView.f19603i[seekBar.getProgress()]);
            }
        }
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$c */
    /* loaded from: classes2.dex */
    public class C4384c implements AdapterView.OnItemSelectedListener {
        public C4384c() {
            NovelSettingView.this = r1;
        }

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
            if ((NovelSettingView.this.f19604a.f22159t.getTag() == null || ((Integer) NovelSettingView.this.f19604a.f22159t.getTag()).intValue() == i) ? false : true) {
                NovelSettingView novelSettingView = NovelSettingView.this;
                if (novelSettingView.f19609f != null) {
                    Typeface a = novelSettingView.f19605b.m4478a(i);
                    NovelSettingView novelSettingView2 = NovelSettingView.this;
                    OnFontChangedListener onFontChangedListener = novelSettingView2.f19609f;
                    Objects.requireNonNull(novelSettingView2.f19605b);
                    onFontChangedListener.onFontChanged(a, i != 1 ? i != 2 ? "default" : "mincho" : "gothic");
                }
            }
            NovelSettingView.this.f19604a.f22159t.setTag(Integer.valueOf(i));
        }

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$d */
    /* loaded from: classes2.dex */
    public class C4385d implements AdapterView.OnItemSelectedListener {
        public C4385d() {
            NovelSettingView.this = r1;
        }

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
            if ((NovelSettingView.this.f19604a.f22158s.getTag() == null || ((Integer) NovelSettingView.this.f19604a.f22158s.getTag()).intValue() == i) ? false : true) {
                NovelSettingView novelSettingView = NovelSettingView.this;
                if (novelSettingView.f19610g != null) {
                    Objects.requireNonNull(novelSettingView.f19606c);
                    int i2 = i != 1 ? i != 2 ? R.color.novel_background_white : R.color.novel_background_sepia : R.color.novel_background_black;
                    int a = NovelSettingView.this.f19606c.m4479a(i);
                    Objects.requireNonNull(NovelSettingView.this.f19606c);
                    int i3 = i != 1 ? i != 2 ? R.color.novel_page_counter_white : R.color.novel_page_counter_sepia : R.color.novel_page_counter_black;
                    NovelSettingView novelSettingView2 = NovelSettingView.this;
                    OnColorChangedListener onColorChangedListener = novelSettingView2.f19610g;
                    Objects.requireNonNull(novelSettingView2.f19606c);
                    onColorChangedListener.onColorChanged(i2, a, i3, i != 1 ? i != 2 ? "white" : "sepia" : "black");
                }
            }
            NovelSettingView.this.f19604a.f22158s.setTag(Integer.valueOf(i));
        }

        @Override // android.widget.AdapterView.OnItemSelectedListener
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$e */
    /* loaded from: classes2.dex */
    public class C4386e extends BaseAdapter {

        /* renamed from: a */
        public String[] f19615a;

        public C4386e() {
            NovelSettingView.this = r2;
            this.f19615a = r2.getResources().getStringArray(R.array.novel_background_names);
        }

        /* renamed from: a */
        public int m4479a(int i) {
            return i != 1 ? i != 2 ? R.color.novel_text_white : R.color.novel_text_sepia : R.color.novel_text_black;
        }

        @Override // android.widget.Adapter
        public int getCount() {
            return this.f19615a.length;
        }

        @Override // android.widget.BaseAdapter, android.widget.SpinnerAdapter
        public View getDropDownView(int i, View view, ViewGroup viewGroup) {
            SpinnerDropdownItemNovelBackgroundBinding t5Var;
            RelativeLayout relativeLayout;
            if (view != null) {
                t5Var = (SpinnerDropdownItemNovelBackgroundBinding) view.getTag();
                relativeLayout = view;
            } else {
                View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.spinner_dropdown_item_novel_background, viewGroup, false);
                int i2 = R.id.spinner_item_novel_background_name;
                TextView textView = (TextView) ViewBindings.m9835b(inflate, R.id.spinner_item_novel_background_name);
                if (textView != null) {
                    i2 = R.id.spinner_item_novel_background_sample;
                    TextView textView2 = (TextView) ViewBindings.m9835b(inflate, R.id.spinner_item_novel_background_sample);
                    if (textView2 != null) {
                        RelativeLayout relativeLayout2 = (RelativeLayout) inflate;
                        t5Var = new SpinnerDropdownItemNovelBackgroundBinding(relativeLayout2, textView, textView2);
                        relativeLayout2.setTag(t5Var);
                        relativeLayout = relativeLayout2;
                    }
                }
                throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
            }
            int i3 = i != 1 ? i != 2 ? R.drawable.novel_settings_background_white : R.drawable.novel_settings_background_sepia : R.drawable.novel_settings_background_black;
            int a = m4479a(i);
            t5Var.f22282c.setBackgroundResource(i3);
            TextView textView3 = t5Var.f22282c;
            Context context = NovelSettingView.this.getContext();
            Object obj = ContextCompat.f19963a;
            textView3.setTextColor(ContextCompat.C4473d.m4257a(context, a));
            t5Var.f22281b.setText(this.f19615a[i]);
            return relativeLayout;
        }

        @Override // android.widget.Adapter
        public Object getItem(int i) {
            return this.f19615a[i];
        }

        @Override // android.widget.Adapter
        public long getItemId(int i) {
            return (long) i;
        }

        @Override // android.widget.Adapter
        public View getView(int i, View view, ViewGroup viewGroup) {
            SpinnerItemNovelBackgroundBinding v5Var = (SpinnerItemNovelBackgroundBinding) C1060c.m10358a(viewGroup, R.layout.spinner_item_novel_background, viewGroup, false);
            View view2 = v5Var.f2666e;
            view2.setTag(v5Var);
            int i2 = i != 1 ? i != 2 ? R.drawable.novel_settings_background_white : R.drawable.novel_settings_background_sepia : R.drawable.novel_settings_background_black;
            int a = m4479a(i);
            v5Var.f22346r.setBackgroundResource(i2);
            TextView textView = v5Var.f22346r;
            Context context = NovelSettingView.this.getContext();
            Object obj = ContextCompat.f19963a;
            textView.setTextColor(ContextCompat.C4473d.m4257a(context, a));
            v5Var.f22345q.setText(this.f19615a[i]);
            return view2;
        }
    }

    /* renamed from: jp.pxv.android.view.NovelSettingView$f */
    /* loaded from: classes2.dex */
    public static class C4387f extends BaseAdapter {

        /* renamed from: a */
        public String[] f19617a;

        public C4387f(Context context) {
            this.f19617a = context.getResources().getStringArray(R.array.novel_font_names);
        }

        /* renamed from: a */
        public Typeface m4478a(int i) {
            if (i == 0) {
                return Typeface.DEFAULT;
            }
            if (i == 1) {
                return ((NovelTypeface) C2518n.m7641d(NovelTypeface.class)).f23069a;
            }
            if (i != 2) {
                return null;
            }
            return ((NovelTypeface) C2518n.m7641d(NovelTypeface.class)).f23070b;
        }

        @Override // android.widget.Adapter
        public int getCount() {
            return this.f19617a.length;
        }

        @Override // android.widget.BaseAdapter, android.widget.SpinnerAdapter
        public View getDropDownView(int i, View view, ViewGroup viewGroup) {
            SpinnerDropdownItemNovelFontBinding u5Var;
            RelativeLayout relativeLayout;
            if (view != null) {
                u5Var = (SpinnerDropdownItemNovelFontBinding) view.getTag();
                relativeLayout = view;
            } else {
                View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.spinner_dropdown_item_novel_font, viewGroup, false);
                int i2 = R.id.spinner_item_ic_novel_font_large;
                TextView textView = (TextView) ViewBindings.m9835b(inflate, R.id.spinner_item_ic_novel_font_large);
                if (textView != null) {
                    i2 = R.id.spinner_item_novel_font;
                    TextView textView2 = (TextView) ViewBindings.m9835b(inflate, R.id.spinner_item_novel_font);
                    if (textView2 != null) {
                        i2 = R.id.spinner_item_novel_font_small;
                        TextView textView3 = (TextView) ViewBindings.m9835b(inflate, R.id.spinner_item_novel_font_small);
                        if (textView3 != null) {
                            RelativeLayout relativeLayout2 = (RelativeLayout) inflate;
                            u5Var = new SpinnerDropdownItemNovelFontBinding(relativeLayout2, textView, textView2, textView3);
                            relativeLayout2.setTag(u5Var);
                            relativeLayout = relativeLayout2;
                        }
                    }
                }
                throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
            }
            u5Var.f22314c.setText(this.f19617a[i]);
            Typeface a = m4478a(i);
            if (a != null) {
                u5Var.f22315d.setTypeface(a);
                u5Var.f22313b.setTypeface(a);
                u5Var.f22314c.setTypeface(a);
            }
            return relativeLayout;
        }

        @Override // android.widget.Adapter
        public Object getItem(int i) {
            return this.f19617a[i];
        }

        @Override // android.widget.Adapter
        public long getItemId(int i) {
            return (long) i;
        }

        @Override // android.widget.Adapter
        public View getView(int i, View view, ViewGroup viewGroup) {
            SpinnerItemNovelFontBinding x5Var = (SpinnerItemNovelFontBinding) C1060c.m10358a(viewGroup, R.layout.spinner_item_novel_font, viewGroup, false);
            x5Var.f22451r.setText(this.f19617a[i]);
            Typeface a = m4478a(i);
            if (a != null) {
                x5Var.f22452s.setTypeface(a);
                x5Var.f22450q.setTypeface(a);
                x5Var.f22451r.setTypeface(a);
            }
            return x5Var.f2666e;
        }
    }

    public NovelSettingView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet, 0);
        setOrientation(1);
        C4387f fVar = new C4387f(getContext());
        this.f19605b = fVar;
        this.f19604a.f22159t.setAdapter((SpinnerAdapter) fVar);
        C4386e eVar = new C4386e();
        this.f19606c = eVar;
        this.f19604a.f22158s.setAdapter((SpinnerAdapter) eVar);
    }

    public void setColor(String str) {
        char c;
        AppCompatSpinner appCompatSpinner = this.f19604a.f22158s;
        Objects.requireNonNull(this.f19606c);
        int hashCode = str.hashCode();
        int i = 0;
        if (hashCode == 93818879) {
            if (str.equals("black")) {
                c = 2;
            }
            c = 65535;
        } else if (hashCode != 109324790) {
            if (hashCode == 113101865 && str.equals("white")) {
                c = 0;
            }
            c = 65535;
        } else {
            if (str.equals("sepia")) {
                c = 3;
            }
            c = 65535;
        }
        if (c == 2) {
            i = 1;
        } else if (c == 3) {
            i = 2;
        }
        appCompatSpinner.setSelection(i);
    }

    public void setFontSize(float f) {
        int i = 0;
        while (true) {
            float[] fArr = f19602h;
            if (i < fArr.length) {
                if (f == fArr[i]) {
                    this.f19604a.f22156q.setProgress(i);
                }
                i++;
            } else {
                return;
            }
        }
    }

    public void setFontType(String str) {
        char c;
        AppCompatSpinner appCompatSpinner = this.f19604a.f22159t;
        Objects.requireNonNull(this.f19605b);
        int hashCode = str.hashCode();
        int i = 0;
        if (hashCode == -1240094858) {
            if (str.equals("gothic")) {
                c = 2;
            }
            c = 65535;
        } else if (hashCode != -1074044648) {
            if (hashCode == 1544803905 && str.equals("default")) {
                c = 0;
            }
            c = 65535;
        } else {
            if (str.equals("mincho")) {
                c = 3;
            }
            c = 65535;
        }
        if (c == 2) {
            i = 1;
        } else if (c == 3) {
            i = 2;
        }
        appCompatSpinner.setSelection(i);
    }

    public void setLineSpace(float f) {
        int i = 0;
        while (true) {
            float[] fArr = f19603i;
            if (i < fArr.length) {
                if (f == fArr[i]) {
                    this.f19604a.f22157r.setProgress(i);
                }
                i++;
            } else {
                return;
            }
        }
    }

    public void setOnColorChangedListener(OnColorChangedListener onColorChangedListener) {
        this.f19610g = onColorChangedListener;
        this.f19604a.f22158s.setOnItemSelectedListener(new C4385d());
    }

    public void setOnFontChangedListener(OnFontChangedListener onFontChangedListener) {
        this.f19609f = onFontChangedListener;
        this.f19604a.f22159t.setOnItemSelectedListener(new C4384c());
    }

    public void setOnFontSizeChangedListener(OnFontSizeChangedListener onFontSizeChangedListener) {
        this.f19607d = onFontSizeChangedListener;
        this.f19604a.f22156q.setOnSeekBarChangeListener(new C4382a());
    }

    public void setOnLineSpaceChangedListener(OnLineSpaceChangedListener onLineSpaceChangedListener) {
        this.f19608e = onLineSpaceChangedListener;
        this.f19604a.f22157r.setOnSeekBarChangeListener(new C4383b());
    }
}
